//路径为 '@/apis/address.js'

import axiosInstance from './axiosInstance';

const addressAPI = {
  // 获取用户的所有地址
  getUserAddresses: () => {
    return axiosInstance.get('/api/addresses');
  },

  // 获取单个地址详情
  getAddress: (id) => {
    return axiosInstance.get(`/api/addresses/${id}`);
  },

  // 添加新地址
  addAddress: (addressData) => {
    return axiosInstance.post('/api/addresses', addressData);
  },

  // 更新现有地址
  updateAddress: (id, addressData) => {
    return axiosInstance.put(`/api/addresses/${id}`, addressData);
  },

  // 删除地址
  deleteAddress: (id) => {
    return axiosInstance.delete(`/api/addresses/${id}`);
  },

  // 设置默认地址
  setDefaultAddress: (id) => {
    return axiosInstance.put(`/api/addresses/${id}/default`);
  },

  // 获取用户地址数量
  getAddressCount: () => {
    return axiosInstance.get('/api/addresses/count');
  }
};

export default addressAPI;